I'm working on a project in React and ran into a problem that has me stumped.
Whenever I run yarn start I get this error:
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
I have no idea why this is happening, if anyone has experienced this I would be grateful.
To fix this issue simply upgrade react-scripts package (check latest version with npm info react-scripts version):
"react-scripts": "^3.x.x" with "react-scripts": "^3.4.1" (or the latest available version)npm install or yarn installSome people reported that this issue was caused by running npm audit fix (avoid it!).
If you have ejected, this is the proper way to fix this issue:
find this file config/webpackDevServer.config.js and then inside this file find the following line:
app.use(noopServiceWorkerMiddleware());
You should change it to:
app.use(noopServiceWorkerMiddleware('/'));
For me(and probably most of you) the service worker is served at the root of the project. In case it's different for you, you can pass your base path instead.
I've also faced this problem and figure out it by upgrading the react-scripts package from "react-scripts": "3.x.x" to "react-scripts": "^3.4.1" (or the latest available version).
node_modules\ folderpackage-lock.json filepackage.json file from "react-scripts": "3.x.x" to "react-scripts": "^3.4.1"npm inpm startAnd it works!!